﻿using HomagChina.CCHCS.DataTypeModel;
using HomagGroup.BaseUI.Router;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;

namespace HomagChina.CCHCS.ViewModels
{
    public partial class MainWindowViewModel : HomagGroup.Base.UI.NotifyPropertyChangedBase
    {
        #region Conponents

        private ObservableCollection<FunctionKeyBarItemDataModel> _functionKeyBarMenu;

        public ObservableCollection<FunctionKeyBarItemDataModel> FunctionKeyBarMenu
        {
            get => _functionKeyBarMenu;
            set { _functionKeyBarMenu = value; OnPropertyChanged(); }
        }

        private UIElement _ContentElement;

        public UIElement ContentElement
        { get => _ContentElement; set { _ContentElement = value; OnPropertyChanged(); } }

        public ObservableCollection<RouterItemDataModel> RouterItems { get; }

        private RouterItemDataModel _CurrentRouter = new RouterItemDataModel() { ID = "Home" };

        public RouterItemDataModel CurrentRouter
        {
            get => _CurrentRouter;
            set
            {
                if (value == null || value.ID == _CurrentRouter.ID) return;
                _CurrentRouter = value;
                if (value.ID.Equals("Home"))
                {
                    NavigateServices.Instance.NavigateTo(value.ID);
                }

                while (RouterItems.LastOrDefault() != value)
                {
                    RouterItems.Remove(RouterItems.Last());
                }
                OnPropertyChanged();
            }
        }

        #endregion Conponents

        public MainWindowViewModel()
        {
            RouterItems = new ObservableCollection<RouterItemDataModel>();
            FunctionKeyBarMenu = new ObservableCollection<FunctionKeyBarItemDataModel>();
            //UIAdjustments.CurrentThreadLanguageManager.CultureChanged += NavigateServices.Instance.LanguageManagerCultureChanged;
        }
    }
}